import requests
from config import BASE_URL


# 定义接口类
class ApiEmpManager(object):
    # 设置url属性
    def __init__(self):
        # 添加员工url
        self.__add_url = BASE_URL + "/api/sys/user"
        # 查询/修改/删除员工url
        self.__qmd_url = BASE_URL + "/api/sys/user/{}"
        # 修改员工url
        # self.__modify_url = BASE_URL + "/api/sys/user/{}"

    # 添加员工接口方法
    def add_emp(self, header, req_data):
        # 发送添加员工请求
        res = requests.post(url=self.__add_url, headers=header, json=req_data)
        # 返回结果
        return res

    # 查询员工接口方法
    def query_emp(self, uid, header):
        res = requests.get(url=self.__qmd_url.format(uid), headers=header)
        return res

    # 修改员工接口方法
    def modify_emp(self, uid, header, req_data):
        res = requests.put(url=self.__qmd_url.format(uid), headers=header, json=req_data)
        return res

    # 删除员工接口方法
    def delete_emp(self, uid, header):
        res = requests.delete(url=self.__qmd_url.format(uid), headers=header)
        return res


if __name__ == '__main__':
    # 实参
    # req_data = {"username": "张三", "mobile": "13812340131", "workNumber": "12312"}
    header = {"Content-Type": "application/json", "Authorization": "Bearer 9986204e-5c97-4e72-82a5-77f0819e1d05"}
    # 创建对象
    api_emp = ApiEmpManager()
    # # 调用方法
    # result = api_emp.add_emp(header, req_data)
    # print(result.json())
    uid = "1579016592363106304"
    print(api_emp.query_emp(uid, header).json())
